<?php


namespace app\api\controller\v34;


use app\api\controller\v13\Auth2;
use app\common\cachemodel\zl1_relation\Zl1RelationAnalysisIdea;
use app\common\lib\Util;
use think\Env;

/**
 * 关系研究所    2.9.1
 * Class RelationAnalysis
 * @package app\api\controller\v34
 */
class RelationAnalysis extends Auth2
{
    /**
     * 关系研究所 首页
     */
    public function index()
    {
        $rid = input('rid/d', 0);

        if ($this->user)
        {
            if ($rid)
            {
                $recode = (new \app\common\cachemodel\Recode())->getInfoById($rid);
                if (!$recode || $recode['uid'] != $this->user['id'])
                {
                    return show(config('code.error'), '当前档案不存在');
                }

                $nickname = $recode['name'];
                $avatar = $recode['avatar'];
                // 我的爱情关键词：金星落座
                $venuData = $recode['venu']; // 8-2-233.5532719
                $venuArr = explode('-', $venuData);
                $venuInSign = (int)$venuArr[0];
                $textArr = [
                    1 => ['坦率直接', '三分钟热度', '勇敢追爱'],
                    2 => ['注重感官享受', '及时行乐', '主观顽固'],
                    3 => ['睿智多变', '高度幽默感', '调情高手'],
                    4 => ['既现实又浪漫', '善于自我保护', '极需安全感'],
                    5 => ['疾风暴雨般浪漫', '霸道总裁强制爱', '不可侵犯的尊严'],
                    6 => ['精致细腻', '服务型人格', '重视诺言'],
                    7 => ['唯美主义', '懂得生活情调', '平等随和'],
                    8 => ['高度敏锐', '极端控制欲', '狡猾的猎手'],
                    9 => ['难以被束缚', '乐观主义', '追求精神共鸣'],
                    10 => ['传统保守', '对爱情专注', '不轻易被诱惑'],
                    11 => ['内心洒脱', '近距离恐惧症', '不受传统观念限制'],
                    12 => ['渴望关注与共鸣', '任性爱“作”', '偶像剧式的爱情'],
                ];
                $loveKeyword = $textArr[$venuInSign] ?? ['我是谁', '我在哪', '我在干什么'];
            } else
            {
                $nickname = $this->user['nickname'];
                $avatar = $this->user['avatar'];
                $loveKeyword = [];
            }
            $unLockCaseData = (new Zl1RelationAnalysisIdea())->getUnlockCaseList($this->user['id']);
            $isUnLock = empty($unLockCaseData) ? false : true;
        } else
        {
            $loveKeyword = [];
            $isUnLock = false;
            $rid = 0;
        }
        $host = Env::get('host.domain');

        $resData = [
            'data_list' => [
                [
                    'title' => '爱情专区',
                    'list1' => [
                        [
                            'title' => '我的爱情关键词',
                            'love_keyword' => $loveKeyword,
                            'target' => 'local',
                            'link' => 'empty',
                        ]
                    ],
                    'list2' => [
                        [
                            'img' => '/test/relation_analysis/follow.png',
                            'title' => '怎么追求Ta',
                            'des' => '喜欢一个人该怎么追？',
                            'target' => 'link',
                            'link' => $host . "/web/relation_research_fit_you/follow?rid1={$rid}&rid2=0&order_id=&history_id=0&need_auth=0&zhunle_not_show_nav=1&zhunle_nav_text_color=1",
                            'icon' => '/test/relation_analysis/relation_research_new_icon.png'
                        ],
//                        [
//                            'img' => '/test/relation_analysis/check_player.png',
//                            'title' => '鉴“渣”神器',
//                            'des' => '远离不靠谱的恋爱关系',
//                            'target' => 'link',
//                            'link' => $host . "/web/relation_research_fit_you/check_player?rid=0&order_id=&history_id=0&need_auth=0&zhunle_not_show_nav=1&zhunle_nav_text_color=1",
//                            'icon' => '/test/relation_analysis/relation_research_new_icon.png'
//                        ],
                        [
                            'img' => '/test/relation_analysis/fit.png',
                            'title' => '适合你的Ta',
                            'des' => '什么样的人更适合你？',
                            'target' => 'link',
                            'link' => $host . "/web/relation_research_fit_you/index?rid={$rid}&need_auth=1&zhunle_not_show_nav=1&zhunle_nav_text_color=1",
                            'icon' => ''
                        ], [
                            'img' => '/test/relation_analysis/idea.png',
                            'title' => '你的理想型',
                            'des' => '理想型的范围预测～',
                            'target' => 'local',
                            'link' => $isUnLock ? 'relation_research_ideal_result_list?need_auth=2' : 'relation_research_ideal_page?need_auth=2',
                            'icon' => ''
                        ],
                    ]
                ],
            ],
            'name' => $nickname ?? '',
            'avatar' => $avatar ?? '',
            'is_show_more_tips' => 1
        ];

        $rec = Util::CheckAppVersion('2.13.0');
        if ($rec === '大')
        {
            array_unshift($resData['data_list'][0]['list2'], [
                'img' => '/test/relation_analysis/check_player.png',
                'title' => '鉴“渣”神器',
                'des' => '远离不靠谱的恋爱关系',
                'target' => 'link',
                'link' => $host . "/web/relation_research_fit_you/check_player?rid=0&order_id=&history_id=0&need_auth=0&zhunle_not_show_nav=1&zhunle_nav_text_color=1",
                'icon' => '/test/relation_analysis/relation_research_new_icon.png'
            ]);
        }

        return show(config('code.success'), '请求成功', $resData);
    }
}
